## CVRA plots
setwd("C:\\Papers\\CVRA\\Replication Materials")

events <- seq(-10, 5, 1)

coefficients <- c(  .1583918,
                    .1263849,
                    -.020268,
                    .0986195,
                    .0997632,
                    .0302369,
                   -.0017803,
                    .1208027,
                   -.0159598,
                    .0165152,
                           0,
                    .4379484,
                    .4533019,
                    .7879126,
				     .658787,
                    .6256573
)

lower.ci <- c( -.3623006,   
               -.1187947,
                -.206325,
               -.0641513,
                -.047876,
               -.1219854,
               -.1449742,
               -.0458217,
               -.1673636,
               -.1101776,
					   0,
                .3030852,
                 .315919,
                .5903537,
			    .4512026,
			      .28919
)

upper.ci <- c(.6790841,
              .3715645,
              .1657889,
              .2613903,
              .2474023,
              .1824592,
              .1414137,
              .2874271,
              .1354439,
              .1432079,
					 0,
              .5728116,
              .5906848,
              .9854716,
			  .8663714,
			  .9621246
)

setEPS()
postscript("Figure1.eps")
plot(coefficients[1:11] ~ events[1:11], ylim=c(-0.5,1), xlim=c(-10.5,5.5), xlab="Elections Since Switching to Districts", ylab="Change in Uncontested Seats per Election (ATT)", pch=16, cex=2, col="dodgerblue2", xaxt="n", las=2)
axis(side=1, at=events, labels=events, cex.axis=0.75)
points(coefficients[12:16] ~ events[12:16], pch=16, cex=2, col="firebrick2")
segments(events[1:11], lower.ci[1:11], x1=events[1:11], y1=upper.ci[1:11], lwd=2, col="dodgerblue2")
segments(events[12:16], lower.ci[12:16], x1=events[12:16], y1=upper.ci[12:16], lwd=2, col="firebrick2")
abline(h=0)
abline(v=0, lty="longdash")
dev.off()


events <- seq(-10, 5, 1)

coefficients <- c(   1.055489,
                    -.2630402,
                    -.4904665,
                    -.5993153,
                    -.6577776,
                    -.4945694,
                    -.4937044,
                    -.8341581,
                    -.2533025,
                    -.1838976,
                            0,
                    -.8865676,
                    -1.205871,
                    -2.273273,
				    -1.650068,
                    -1.272621
)

lower.ci <- c( -.4469543,   
               -1.160182,
               -1.267462,
               -1.187338,
               -1.160156,
               -1.050351,
               -.9781783,
               -1.474868,
               -.7573784,
               -.6236495,
					   0,
                -1.40024,
               -1.828034,
               -3.134493,
			   -2.343217,
			   -2.320378
)

upper.ci <- c(  2.557932,
                .6341011,
                .2865291,
                -.011293,
               -.1553994,
                .0612118,
               -.0092304,
               -.1934482,
                .2507735,
                .2558543,
					   0,
               -.3728949,
                -.583707,
               -1.412053,
			   -.9569191,
			   -.2248643
)

setEPS()
postscript("Figure2.eps")
plot(coefficients[1:11] ~ events[1:11], ylim=c(-3.5,2.5), xlim=c(-10.5,5.5), xlab="Elections Since Switching to Districts", ylab="Change in Candidates per Election (ATT)", pch=16, cex=2, col="dodgerblue2", xaxt="n", las=2)
axis(side=1, at=events, labels=events, cex.axis=0.75)
points(coefficients[12:16] ~ events[12:16], pch=16, cex=2, col="firebrick2")
segments(events[1:11], lower.ci[1:11], x1=events[1:11], y1=upper.ci[1:11], lwd=2, col="dodgerblue2")
segments(events[12:16], lower.ci[12:16], x1=events[12:16], y1=upper.ci[12:16], lwd=2, col="firebrick2")
abline(h=0)
abline(v=0, lty="longdash")
dev.off()
